$(function () {
    getProcessInfo();
    getPickerInfo();
    time();
    $.ajax({
        url: Feng.ctxPath + "/consultant/getDoctor",
        type: "get",
        success: function (data) {
            var txt = '<option value="">--请选择医生--</option>';
            for (var i = 0; i < data.length; i++) {
                txt += '<option value="' + data[i].doctor + '">' + data[i].doctor + '</option>';
            }
            document.getElementById('doctor1').innerHTML = txt;
            var seleteDoctorValue = $('#userName').val();
            if (seleteDoctorValue != "") {
                $("#doctor1 option[value=" + seleteDoctorValue + "]").attr("selected", "selected");
            }
        },
        error: function (data) {
            alert('没有权限，请联系管理员!');
        }
    });
    $.ajax({
        url: Feng.ctxPath + "/outpatientManagement/getList",
        type: "post",
        success: function (data) {
            var txt = '<option value="">--请选择门店--</option>';
            for (var i = 0; i < data.length; i++) {
                txt += '<option value="' + data[i].simplename + '">' + data[i].simplename + '</option>';
            }
            document.getElementById('store').innerHTML = txt;
            var seleteStoreValue = $('#storeValue').val();
            if (seleteStoreValue != "") {
                $("#store option[value=" + seleteStoreValue + "]").attr("selected", "selected");
            }
        },
        error: function (data) {
            alert('没有权限，请联系管理员!');
        }
    });
    $.ajax({
        url: Feng.ctxPath + "/doctorLooked/getPayServiceNameList",
        type: "post",
        success: function (data) {
            var txt = '<option value="">--选择耗材--</option>';
            for (var i = 0; i < data.length; i++) {
                txt += '<option value="' + data[i].name + '">' + data[i].name + '</option>';
            }
            document.getElementById('payServiceNameM').innerHTML = txt;
            var payServiceNameMValue = $('#payServiceNameM').val();
            if (payServiceNameMValue != "") {
                $("#payServiceNameM option[value=" + payServiceNameMValue + "]").attr("selected", "selected");
            }
        },
        error: function (data) {
            alert('没有权限，请联系管理员!');
        }
    });
})
function addSetUint() {//添加加工单位
    var index = layer.open({
        type: 2,
        title: '添加加工单位',
        area: ['60%', '60%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/doctorLooked/add_unit'
    });
    this.layerIndex = index;
}
function addPicker() {//添加取件人
    var index = layer.open({
        type: 2,
        title: '添加取件人',
        area: ['60%', '60%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/doctorLooked/add_picker'
    });
    this.layerIndex = index;
}
function getProcessInfo() {
    $.ajax({
        url: Feng.ctxPath + "/doctorLooked/getProcessInfo",
        type: "POST",
        success: function (data) {
            var txt = '<option value="">--请选择加工单位--</option>';
            for (var i = 0; i < data.length; i++) {
                txt += '<option value="' + data[i].processUnit + '">' + data[i].processUnit + '</option>';
            }
            document.getElementById('processUnit').innerHTML = txt;
            var seleteProcessUnitValue = $('#processUnit').val();
            if (seleteProcessUnitValue != "") {
                $("#processUnit option[value=" + seleteProcessUnitValue + "]").attr("selected", "selected");
            }
        },
        error: function (data) {
            alert('没有权限，请联系管理员!');
        }
    });
}
function getPickerInfo() {
    $.ajax({
        url: Feng.ctxPath + "/doctorLooked/getPickerInfo",
        type: "POST",
        success: function (data) {
            var txt = '<option value="">--请选择取件人--</option>';
            for (var i = 0; i < data.length; i++) {
                txt += '<option value="' + data[i].picker + '">' + data[i].picker + '</option>';
            }
            document.getElementById('picker').innerHTML = txt;
            var seletePickerValue = $('#picker').val();
            if (seletePickerValue != "") {
                $("#picker option[value=" + seletePickerValue + "]").attr("selected", "selected");
            }
        },
        error: function (data) {
            alert('没有权限，请联系管理员!');
        }
    });
}
function time() {//初始化赋值时间
    var time = new Date();
    var month = time.getMonth() + 1;
    var day = time.getDate();
    var hour = time.getHours();
    var minutes = time.getMinutes();
    if (month < 10) {
        month = "0" + month
    }
    if (day < 10) {
        day = "0" + day
    }
    if (hour < 10) {
        hour = "0" + hour
    }
    if (minutes < 10) {
        minutes = "0" + minutes
    }
    $("#deliveryTime").val(time.getFullYear() + "-" + month + "-" + day+" "+hour+":"+minutes); //送件时间
    $("#pickUpTime").val(time.getFullYear() + "-" + month + "-" + day+" "+hour+":"+minutes);  //取件时间
};